﻿using DevExpress.XtraGrid.Demos.util;
using DXApplicationTangche.DTO;
using mendian;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DXApplicationTangche.UC.有赞.Service
{
    public class 有赞商品Service
    {
        /// <summary>
        /// spu服装属性维护
        /// </summary>
        /// <param name="itemId"></param>
        /// <param name="styleNameCn"></param>
        /// <param name="materialCode"></param>
        /// <param name="materialName"></param>
        /// <param name="composition"></param>
        /// <param name="refBarcode"></param>
        /// <param name="salePrice"></param>
        /// <param name="onlineSalePrice"></param>
        /// <returns></returns>
        public static ViewSpuCostDao saveSpuCost(
            int itemId,
            String styleNameCn,
            String materialCode,
            String materialName,
            String composition,
            String refBarcode,
            Double salePrice,
            Double onlineSalePrice
            )
        {
            return
                FunctionHelper.JsonDeserialization<ViewSpuCostDao>(
                    RestCall.httpGetMethod(
                        URL.接口url1 + "/youzan/saveSpuCost?itemId=" + itemId
                        + "&styleNameCn=" + styleNameCn
                        + "&materialCode=" + materialCode
                        + "&materialName=" + materialName
                        + "&composition=" + composition
                        + "&refBarcode=" + refBarcode
                        + "&salePrice=" + salePrice
                        + "&onlineSalePrice=" + onlineSalePrice
                        )
                    );
        }
        /// <summary>
        /// 查询spu带服装属性一览
        /// </summary>
        /// <returns></returns>
        public static List<ViewSpuCostDao> getViewSpuCostList()
        {
            return
                FunctionHelper.JsonDeserialization<List<ViewSpuCostDao>>(
                    RestCall.httpGetMethod(
                        URL.接口url1 + "/youzan/getViewSpuCostList"
                    )
                );
        }

        /// <summary>
        /// spu和sku一览
        /// </summary>
        /// <returns></returns>
        public static List<YouzanSpuCostStockDTO> getYouzanSpuCostStockAll()
        {
            return
                FunctionHelper.JsonDeserialization<List<YouzanSpuCostStockDTO>>(
                    RestCall.httpGetMethod(
                        URL.接口url1 + "/youzan/getYouzanSpuCostStockAll"
                    )
                );
        }

        /// <summary>
        /// 保存有赞spu和sku数据库
        /// </summary>
        /// <returns></returns>
        public static String saveYouzanSpuItemsAndSkusByGroup(String groupAlias, int groupId, String groupName)
        {
            return
                RestCall.httpGetMethod(
                    URL.接口url1 + "/youzan/saveYouzanSpuItemsAndSkusByGroup?groupAlias=" + groupAlias + "&groupId=" + groupId + "&groupName=" + groupName
                );
        }
    }
    public class YouzanSpuCostStockDTO
    {
        /**
         * spu数据
         */
        public int itemId { get; set; }  //     商品Id
        public String detailUrl { get; set; }    //  商品详情链接
        public DateTime createdTime { get; set; }    //  创建时间
        public int itemType { get; set; }    //  商品类型
        public String title { get; set; }    // 商品名称
        public String shareTitle { get; set; }    //  商品名称
        public String origin { get; set; }    //  划线价
        public Double price { get; set; }    // 商品价格
        public int quantity { get; set; }    // 总库存
        public String groupAlias { get; set; }
        public String groupId { get; set; }
        public String groupName { get; set; }
        public String imageUrl { get; set; }
        //  价格体系
        public String styleCode { get; set; }
        public String styleName { get; set; }   //  款名
        public String materialCode { get; set; }
        public String materialName { get; set; }    //  面料名
        public String composition { get; set; } //  成分
        public String refBarcode { get; set; } //   参考码
        public Double salePrice { get; set; }   //  零售价，吊牌价
        public Double onlineSalePrice { get; set; } //  电商零售价
        public DateTime createDate { get; set; }
        /**
         * sku规格及库存数
         */
        public List<YouzanSkuStockDto> youzanSkuStockDtos { get; set; }

        public YouzanSpuCostStockDTO()
        {

        }
    }

    public class YouzanSkuStockDto
    {
        public int skuId { get; set; } //  	商品规格Id
        public int itemId { get; set; }
        public String spec { get; set; }    //  规格
        public int quantity { get; set; }    // 库存数量

        public YouzanSkuStockDto()
        {

        }
    }
    public class ViewSpuCostDao
    {
        public int itemId { get; set; }  //    商品Id
        public String detailUrl { get; set; }    //  商品详情链接
        public DateTime createdTime { get; set; }    //  创建时间
        public int itemType { get; set; }    //  商品类型
        public String title { get; set; }    // 商品名称
        public String shareTitle { get; set; }    //  商品名称
        public String origin { get; set; }    //  划线价
        public Double price { get; set; }    // 商品价格
        public int quantity { get; set; }    // 总库存
        public String groupAlias { get; set; }
        public String groupId { get; set; }
        public String groupName { get; set; }
        public String imageUrl { get; set; }
        //  价格体系
        public String styleCode { get; set; }
        public String styleName { get; set; }   //  款名
        public String materialCode { get; set; }
        public String materialName { get; set; }    //  面料名
        public String composition { get; set; } //  成分
        public String refBarcode { get; set; } //   参考码
        public Double salePrice { get; set; }   //  零售价，吊牌价
        public Double onlineSalePrice { get; set; } //  电商零售价
        public DateTime createDate { get; set; }
        public ViewSpuCostDao()
        {

        }
    }
}
